<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 用户输入一个三位数，弹出各个数位的和 */
        var num = prompt("请输入一个三位数", );
        var add, a, b, c;
        a = parseInt(num / 100);
        b = parseInt((num - a * 100) / 10);
        c = num - a * 100 - b * 10;
        add = a + b + c;
        alert("各个数位的和为" + add);
    </script>
</body>
</html>